package controller;

import model.Layer;
import utils.ImageUtils;
import view.MainFrame;
import abstraction.ImageOperationDialog;
import dialog.BrigthnessContrastFilterDialog;
import dialog.ColorOperationsFilterDialog;
import dialog.PixelOperationsFilterDialog;

public class FilterController {

	public static void openBrigthnessContrastFilterDialog() {
		Layer layer = MainFrame.getInstance().getDrawingPane()
				.getSelectedLayer();
		ImageOperationDialog dialog = new BrigthnessContrastFilterDialog(
				MainFrame.getInstance(), layer);
		
		dialog.setVisible(true);
		
		if (dialog.getReturnStatus() == ImageOperationDialog.RET_OK) {
			layer.setImage(ImageUtils.deepCopy(dialog.getTransformedImage()));
			MainFrame.getInstance().repaint();
		}
	}

	public static void openPixelFilterDialog() {
		Layer layer = MainFrame.getInstance().getDrawingPane()
				.getSelectedLayer();
		PixelOperationsFilterDialog dialog = new PixelOperationsFilterDialog(
				MainFrame.getInstance(), layer);
		dialog.setVisible(true);
		if (dialog.getReturnStatus() == ImageOperationDialog.RET_OK) {
			layer.setImage(ImageUtils.deepCopy(dialog.getTransformedImage()));
			MainFrame.getInstance().repaint();
		}

	}

	public static void openColorFilterDialog() {
		Layer layer = MainFrame.getInstance().getDrawingPane()
				.getSelectedLayer();
		ColorOperationsFilterDialog dialog = new ColorOperationsFilterDialog(
				MainFrame.getInstance(), layer);
		dialog.setVisible(true);
		if (dialog.getReturnStatus() == ImageOperationDialog.RET_OK) {
			layer.setImage(ImageUtils.deepCopy(dialog.getTransformedImage()));
			MainFrame.getInstance().repaint();
		}
	}

}
